﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Prog
    {
        static void Main(string[] args)
        {

            ForArray();
             RandomdDou1();
            RandomdDou();
        }
       //随机数
            static void ForArray()
        {   int j = 0;
            ArrayList iList = new ArrayList();
            for (int i = 0; i < 10; i++)
            { Random ran = new Random();
                do
                {
                    j = ran.Next(1, 11);
                } while (iList.Contains(j));
                iList.Add(j);
               }
                      foreach (int iRand in iList)
            {
                Console.WriteLine(iRand);
            }
        }

    //4-7之间的随机小数，保留两位小数。

        static void RandomdDou1()       
        {
            Random ran = new Random();

            for (int i = 0; i < 10; i++)
            {
                double dou1 = 4 + ran.NextDouble() * 3;
                string strdou1 = Convert.ToString(dou1);
                Console.WriteLine(strdou1.Substring(0, strdou1.IndexOf(".") + 3));
            }
        	   //0-5之间的随机小数，保留两位小数。
        static void RandomdDou()     
        {
            Random random = new Random();

            for (int i = 0; i < 10; i++)
            {

                double dou = random.NextDouble() * 5;
                string strdou = Convert.ToString(dou);
                


); 
}


        }
    }
}
